# graph.py
class Graph:
    def __init__(self, vertices):
        self.V = vertices
        self.graph = [[float('inf')] * vertices for _ in range(vertices)]
        for i in range(vertices):
            self.graph[i][i] = 0

    def add_edge(self, u, v, w):
        self.graph[u][v] = w
        self.graph[v][u] = w  # 无向图

    def remove_edge(self, u, v):
        self.graph[u][v] = float('inf')
        self.graph[v][u] = float('inf')
